from sqlalchemy import Column, Integer, String, Text, SmallInteger
from mooc.db.database import Base

class UniAccount(Base):
    __tablename__ = "ims_uni_account"

    uniacid = Column(Integer, primary_key=True, autoincrement=True)
    groupid = Column(Integer, nullable=False)
    name = Column(String(100), nullable=False)
    description = Column(String(255), nullable=False)
    default_acid = Column(Integer, nullable=False)
    rank = Column(Integer)
    title_initial = Column(String(1), nullable=False)
    createtime = Column(Integer, nullable=False)
    logo = Column(String(255), nullable=False)
    qrcode = Column(String(255), nullable=False)
    create_uid = Column(Integer, nullable=False)

    class Config:
        from_attributes = True

class UniAccountExtraModules(Base):
    __tablename__ = "ims_uni_account_extra_modules"

    id = Column(Integer, primary_key=True, autoincrement=True)
    uniacid = Column(Integer, index=True, nullable=False)
    modules = Column(Text, nullable=False)

    class Config:
        from_attributes = True

class UniAccountGroup(Base):
    __tablename__ = "ims_uni_account_group"

    id = Column(Integer, primary_key=True, autoincrement=True)
    uniacid = Column(Integer, nullable=False)
    groupid = Column(Integer, nullable=False)

    class Config:
        from_attributes = True

class UniAccountMenus(Base):
    __tablename__ = "ims_uni_account_menus"

    id = Column(Integer, primary_key=True, autoincrement=True)
    uniacid = Column(Integer, index=True, nullable=False)
    menuid = Column(Integer, index=True, nullable=False)
    type = Column(SmallInteger, nullable=False)
    title = Column(String(30), nullable=False)
    sex = Column(SmallInteger, nullable=False)
    group_id = Column(Integer, nullable=False)
    client_platform_type = Column(SmallInteger, nullable=False)
    area = Column(String(50), nullable=False)
    data = Column(Text, nullable=False)
    status = Column(SmallInteger, nullable=False)
    createtime = Column(Integer, nullable=False)
    isdeleted = Column(SmallInteger, nullable=False)

    class Config:
        from_attributes = True

class UniAccountModules(Base):
    __tablename__ = "ims_uni_account_modules"

    id = Column(Integer, primary_key=True, autoincrement=True)
    uniacid = Column(Integer, index=True, nullable=False)
    module = Column(String(50), index=True, nullable=False)
    enabled = Column(SmallInteger, nullable=False)
    settings = Column(Text, nullable=False)
    shortcut = Column(SmallInteger, nullable=False)
    displayorder = Column(Integer, nullable=False)

    class Config:
        from_attributes = True

class UniAccountModulesShortcut(Base):
    __tablename__ = "ims_uni_account_modules_shortcut"

    id = Column(Integer, primary_key=True, autoincrement=True)
    title = Column(String(200), nullable=False)
    url = Column(String(250), nullable=False)
    icon = Column(String(200), nullable=False)
    uniacid = Column(Integer, nullable=False)
    version_id = Column(Integer, nullable=False)
    module_name = Column(String(200), nullable=False)

    class Config:
        from_attributes = True

class UniAccountUsers(Base):
    __tablename__ = "ims_uni_account_users"

    id = Column(Integer, primary_key=True, autoincrement=True)
    uniacid = Column(Integer, index=True, nullable=False)
    uid = Column(Integer, index=True, nullable=False)
    role = Column(String(255), nullable=False)
    rank = Column(SmallInteger, nullable=False)

    class Config:
        from_attributes = True

class UniGroup(Base):
    __tablename__ = "ims_uni_group"

    id = Column(Integer, primary_key=True, autoincrement=True)
    owner_uid = Column(Integer, nullable=False)
    name = Column(String(50), nullable=False)
    modules = Column(Text, nullable=False)
    templates = Column(String(5000), nullable=False)
    uniacid = Column(Integer, index=True, nullable=False)
    uid = Column(Integer, nullable=False)

    class Config:
        from_attributes = True

class UniLinkUniacid(Base):
    __tablename__ = "ims_uni_link_uniacid"

    id = Column(Integer, primary_key=True, autoincrement=True)
    uniacid = Column(Integer, nullable=False)
    link_uniacid = Column(Integer, nullable=False)
    version_id = Column(Integer, nullable=False)
    module_name = Column(String(255), nullable=False)

    class Config:
        from_attributes = True

class UniModules(Base):
    __tablename__ = "ims_uni_modules"

    id = Column(Integer, primary_key=True, autoincrement=True)
    uniacid = Column(Integer, index=True, nullable=False)
    module_name = Column(String(50), nullable=False)

    class Config:
        from_attributes = True

class UniVerifycode(Base):
    __tablename__ = "ims_uni_verifycode"

    id = Column(Integer, primary_key=True, autoincrement=True)
    uniacid = Column(Integer, nullable=False)
    receiver = Column(String(50), nullable=False)
    verifycode = Column(String(6), nullable=False)
    total = Column(SmallInteger, nullable=False)
    createtime = Column(Integer, nullable=False)
    failed_count = Column(Integer)

    class Config:
        from_attributes = True

class UniSettings(Base):
    __tablename__ = "ims_uni_settings"

    uniacid = Column(Integer, primary_key=True)
    passport = Column(String(200), nullable=False)
    oauth = Column(String(100), nullable=False)
    jsauth_acid = Column(Integer, nullable=False)
    notify = Column(String(2000), nullable=False)
    creditnames = Column(String(500), nullable=False)
    creditbehaviors = Column(String(500), nullable=False)
    welcome = Column(String(60), nullable=False)
    default = Column(String(60), nullable=False)
    default_message = Column(String(2000), nullable=False)
    payment = Column(Text, nullable=False)
    stat = Column(String(300), nullable=False)
    default_site = Column(Integer)
    sync = Column(SmallInteger, nullable=False)
    recharge = Column(String(500), nullable=False)
    tplnotice = Column(String(2000), nullable=False)
    grouplevel = Column(SmallInteger, nullable=False)
    mcplugin = Column(String(500), nullable=False)
    exchange_enable = Column(SmallInteger, nullable=False)
    coupon_type = Column(SmallInteger, nullable=False)
    menuset = Column(Text, nullable=False)
    statistics = Column(String(100), nullable=False)
    bind_domain = Column(String(200), nullable=False)
    comment_status = Column(SmallInteger, nullable=False)
    reply_setting = Column(SmallInteger, nullable=False)
    default_module = Column(String(100), nullable=False)
    attachment_limit = Column(Integer, nullable=False)
    attachment_size = Column(String(20), nullable=False)
    sync_member = Column(SmallInteger, nullable=False)
    remote = Column(String(2000), nullable=False)

    class Config:
        from_attributes = True 